/********************************************************************
* @Copyright: Shenzhen Hangshun Chip Technology R&D Co., Ltd 
* @Filename: hk32c030xx_pwr.h
* @brief  : 
* @Author : AE Team  
* @Version: V1.0.0/2022-11-21

********************************************************************/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __HK32C030XX_PWR_H
#define __HK32C030XX_PWR_H

#ifdef __cplusplus
 extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "hk32c030xx_conf.h"

/** @defgroup PWR PWR 
  * @brief PWR driver modules
  * @{
  */
	
	
/** @defgroup PWR_Exported_Constants PWR_Exported_Constants
  * @{
  */ 

#define  PWR_PVDLevel_0                     ((uint16_t)0x0000)     /*!< PVD level 0 */
#define  PWR_PVDLevel_1                     ((uint16_t)0x0020)     /*!< PVD level 1 */
#define  PWR_PVDLevel_2                     ((uint16_t)0x0040)     /*!< PVD level 2 */
#define  PWR_PVDLevel_3                     ((uint16_t)0x0060)     /*!< PVD level 3 */
#define  PWR_PVDLevel_4                     ((uint16_t)0x0080)     /*!< PVD level 4 */
#define  PWR_PVDLevel_5                     ((uint16_t)0x00A0)     /*!< PVD level 5 */
#define  PWR_PVDLevel_6                     ((uint16_t)0x00C0)     /*!< PVD level 6 */
#define  PWR_PVDLevel_7                     ((uint16_t)0x00E0)     /*!< PVD level 7 */

#define IS_PWR_PVD_LEVEL(LEVEL) (((LEVEL) == PWR_PVDLevel_0) || ((LEVEL) == PWR_PVDLevel_1)|| \
                                 ((LEVEL) == PWR_PVDLevel_2) || ((LEVEL) == PWR_PVDLevel_3)|| \
                                 ((LEVEL) == PWR_PVDLevel_4) || ((LEVEL) == PWR_PVDLevel_5)|| \
                                 ((LEVEL) == PWR_PVDLevel_6) || ((LEVEL) == PWR_PVDLevel_7))
		
#define PVD_MODE_IT               ((uint32_t)0x00010000U)
#define PVD_MODE_EVT              ((uint32_t)0x00020000U)

#define PVD_RISING_EDGE           ((uint32_t)0x00000001U)
#define PVD_FALLING_EDGE          ((uint32_t)0x00000002U)
#define PVD_RISING_FALLING        ((uint32_t)0x00000003U)																



#define PWR_Regulator_ON                0
#define PWR_Regulator_LowPower          ((uint32_t)0x00000001)
#define IS_PWR_REGULATOR(REGULATOR) (((REGULATOR) == PWR_Regulator_ON) || \
                                     ((REGULATOR) == PWR_Regulator_LowPower))


#define PWR_SLEEPEntry_WFI              ((uint8_t)0x01)
#define PWR_SLEEPEntry_WFE              ((uint8_t)0x02)
#define IS_PWR_SLEEP_ENTRY(ENTRY) (((ENTRY) == PWR_SLEEPEntry_WFI) || ((ENTRY) == PWR_SLEEPEntry_WFE))
 


#define PWR_STOPEntry_WFI               ((uint8_t)0x01)
#define PWR_STOPEntry_WFE               ((uint8_t)0x02)
#define PWR_STOPEntry_SLEEPONEXIT       ((uint8_t)0x03)
#define IS_PWR_STOP_ENTRY(ENTRY) (((ENTRY) == PWR_STOPEntry_WFI) || ((ENTRY) == PWR_STOPEntry_WFE) ||\
                                  ((ENTRY) == PWR_STOPEntry_SLEEPONEXIT))


#define PWR_FLAG_WU                     PWR_CSR_WUF
#define PWR_FLAG_PVDO                   PWR_CSR_PVDO 

#define IS_PWR_GET_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_PVDO))

#define IS_PWR_CLEAR_FLAG(FLAG) (((FLAG) == PWR_FLAG_WU) || ((FLAG) == PWR_FLAG_PVDO))
																  
/**
  * @}
  */


/**
  * @}
  */


void PWR_DeInit(void);

/* Backup Domain Access function **********************************************/
void PWR_BackupAccessCmd(FunctionalState NewState);

/* PVD configuration functions ************************************************/
void PWR_PVDLevelConfig(uint32_t PWR_PVDLevel, uint32_t PWR_PVDMode, uint32_t PWR_PVDEdge);
void PWR_PVDCmd(FunctionalState NewState); 

/* Low Power modes configuration functions ************************************/
void PWR_EnterSleepMode(uint8_t PWR_SLEEPEntry);
void PWR_EnterSTOPMode(uint32_t PWR_Regulator, uint8_t PWR_STOPEntry);

/* Flags management functions *************************************************/
FlagStatus PWR_GetFlagStatus(uint32_t PWR_FLAG);
void PWR_ClearFlag(uint32_t PWR_FLAG);
#ifdef __cplusplus
}
#endif

#endif /* __HK32C030XX_PWR_H */






